<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="apple-mobile-web-app-title" content="${shopPo.name!}" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<title>${shopPo.name!}</title>
<link href="/css/common.css" type="text/css" rel="stylesheet" />
<link href="/css/index.css" type="text/css" rel="stylesheet" />
<link href="/css/icons.css" type="text/css" rel="stylesheet" />
<link href="/css/product.css" type="text/css" rel="stylesheet" />
<link href="/css/ucenter.css" type="text/css" rel="stylesheet" />
<link href="/css/add2home.css" type="text/css" rel="stylesheet" />

<script src="/js/jquery.js" type="text/javascript"></script>
<script src="/js/caichong_common.js" type="text/javascript"></script>
<script src="/js/jquery.validate.min.js" type="text/javascript"></script>
<style type="text/css">
.input_num {
    border: 1px solid #EAEAEA;
    color: #999999;
    font-size: 12px;
    height: 14px;
    line-height: 14px;
    padding: 2px;
    text-align: center;
    width: 24px;
}

INPUT:checked, .cart-selall:checked
{
	background-image: url();
	background-repeat: no-repeat;
}

.cart-selall {
-webkit-appearance: none;
height: 36px;
width: 36px;
position: absolute;
top: 2px;
right:-1px;
border-radius: 4px;
background: none;
}

</style>
  
<link href="/css/style.css" rel="stylesheet" type="text/css" />
<script src="/js/common.js"></script>
<script>var shop = "shopMer_${shopPo.id!}";var shopCart = "shopcartMer_${(shopPo.id)!}";</script>
<script type="text/javascript">
function decrease_quantity(index){
	var quantity = $("#input_num_"+index).val();
	if(quantity==1){
		return ;
	}else{
		quantity = quantity-1;
		 $("#input_num_"+index).val(quantity);
	}
	sum()
}

function add_quantity(index){
	var quantity = $("#input_num_"+index).val();
	if(quantity<1){
		quantity = 1;
	}
	quantity = Number(quantity)+1;
	$("#input_num_"+index).val(quantity);
	sum()
}


function change_quantity(index,obj){
	var n = Number($(obj).val());
	if(n<1){
		alert("商品购买数量，输入数量应该是一个以上");
		$(obj).val("1");
		n = 1;
	}
	sum()
}


</script>
 </head>
 <body>
 <!--div id="loading">菜单加载中..</div>  -->
 <div id="container">
	
	<div id="header" style="position:fixed;top:0px;">
		<div id="left">
			<a href="/app?id=${(session.session_shop.id)!}&mobileNo=${mobileNo!}"><img src="/images/transparent.png" class="return" /></a>
			<h1>${shopPo.name!}</h1>
		</div>
		<div id="right">
			<!-- <a href="/cart/view/${shopPo.id!}">购物车</a>&nbsp;<a href="/"><img src="/images/transparent.png" class="index" /></a> -->
			<!-- <input type="button" value="一键点菜" onclick="" class="autoDish"> -->
			<div class="top-shortcuts">
				<ul>
					<!-- <li class="ucenter"><a href="/home/login">用户中心</a></li>
					<li class="cates"><a href="/menu/categories">全部分类</a></li> -->
					<li class="cart" id="shoppingcart"><a href="/app/toCart?id=${shopPo.id!}&mobileNo=${mobileNo!}">购物车</a></li>
				</ul>
			</div>
		</div>
	</div>
	
	<div id="menu">
		<div id="leftClassify">
			<ul id="classify" style="margin-top: 0px;top: 82px;">
				<#list productTypeList as type>
					<#if type_index == 0 >
						<li id="classify_${type.id!}" class="selected">${type.name}</li>
					<#elseif type_index gt 0>
						<li id="classify_${type.id!}">${type.name}</li>
					</#if>
				</#list>
				
			</ul>
		</div>
		${map.keySet()!}
		<#list map.keySet() as idKey> 
			<div id="dishes_classify_${idKey!}" class="<#if idKey_index==0>right visible</#if><#if idKey_index gt 0>right hidden</#if>">
			<ul>
			<#list map.get(idKey) as x >
				<li id="dishes_${x.id!}" title="${x.name!}" style="position: relative;">
					<!-- <img src="http://adm.smpay.cn${x.logo!}" onerror="this.src='/images/default.png'" width="90px" height="96px"/> -->
					${x.name!}				
					<img style="display:none" src="/images/transparent.png" class="good" />
					<br/>
					<font style="color: red">￥<label>${x.now_price!}</label>元</font>
					<input type="checkbox" id="dish_${x.id!}" name="dish_${x.id!}" class="cart-selall">
					<!-- <input type="checkbox" id="dish_${x.id!}" class="regular-checkbox" /><label for="dish_${x.id!}"></label> -->
					<br/>
					<span>
					<img style="vertical-align: middle; width:22px;padding-left: 5px;" alt="decrease" onclick="decrease_quantity(${x.id!});" src="/images/subtract.gif">
					<input id="input_num_${x.id!}" class="input_num" type="text" size="20" changed="1" orig="1" value="1" onblur="change_quantity(${x.id!},this)">
					<img style="vertical-align: middle; width:22px" alt="increase" onclick="add_quantity(${x.id!});" src="/images/adding.gif">
					</span>
				</li>
 			</#list>
 			</ul>
 		</div>
   		</#list>
   		
   	
		<div id="orderInfo" style="display:none">
			合计￥<label id="sumPrice">0</label>元 共 <a href="#" onclick="openWindow(totalSelectedDishesTemp());" class="orderList"><label id="sumDishes">0</label>道菜<img src="/images/transparent.png" class="orderListICO" /></a> &nbsp;&nbsp;
			<input type="button" value="菜点好了>> " onclick="toCart()" class="orderSubmit">
		</div>
		<div id="orderInfoA">
			<a href="javascript:showClassify();" id="choose" class="choose"><img src="/images/transparent.png" id="chooseICO" class="chooseICO_B" /> 选择菜品分类</a>
			<a href="javascript:openWindow(totalSelectedDishesTemp());" class="orderList">已点 <label id="sumDishesA">0</label> <img src="/images/transparent.png"  class="orderListICO"  style="top: 0px;height: 24px;"/></a>
			<a href="javascript:toCart()" class="orderSubmit">&nbsp;&nbsp;点好了<img src="/images/transparent.png"  class="orderSubmitICO"  style="top: 0px;height: 24px;"/></a>
		</div>
	</div>
 </div>

  <script type="text/javascript" src="/js/menu_app.js"></script>
  <script type="text/javascript">

	/* var cookieDishes = getCookie(shop).split(",");
	if(cookieDishes != ''){
		for ( i=0 ; i < cookieDishes.length ; i++ ){
			document.getElementById("dishes_" + cookieDishes[i]).style.backgroundColor = '#E1E1E1';
			document.getElementById("dishes_" + cookieDishes[i]).getElementsByTagName("input")[0].checked = true;
			selectedDishes.push(cookieDishes[i]);
		}
	} */
	
	var cookieCartDishes = getCookie(shopCart).split("|");
	if(cookieCartDishes!=''){
		for ( i=0 ; i < cookieCartDishes.length ; i++ ){
			var cookieDish = cookieCartDishes[i].split(",");
			if(cookieDish != ''){
				document.getElementById("dishes_" + cookieDish[0]).style.backgroundColor = '#E1E1E1';
				document.getElementById("dishes_" + cookieDish[0]).getElementsByTagName("input")[0].checked = true;
				//alert(cookieDish[j]);
				document.getElementById("input_num_" + cookieDish[0]).value=cookieDish[1]
				selectedDishes.push(cookieDish[0]);
				
			}
		}
	}
	
	sum();//alert("tests=="+getCookie(shop));

	function toCart(){
		//var telNumber = prompt("请输入您的手机号");
		//sum();
		var dishNum = document.getElementById("sumDishesA").innerHTML;
		if(dishNum=="" || dishNum=="0"){
			Message("至少选择一份！");
			return;
		}
		
		window.location.href = "/app/toCart?id=${shopPo.id!}&mobileNo=${mobileNo!}" ;
		//setCookie(shop,"",30);
	}
  </script>
 </body>
</html>


